// Copyright (c) 2010 School of Software, Tsinghua University, Beijing (China)
// All rights reserved.
//
// This file is part of Geoxiom (http://code.google.com/p/geoxiom/); you may 
// redistribute it under the terms of the GNU Lesser General Public License.
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Author(s) : Kan-Le Shi

#ifndef GEOXIOM_GRAMMAR_NODE_HPP
#define GEOXIOM_GRAMMAR_NODE_HPP

#include "pattern.hpp"

namespace Geoxiom {
namespace Grammar {

typedef class Node {
public:
	PatternPtr pattern;
	WildcardPtr wildcard;
	std::vector<Node *> children;

	Geoxiom::Lex::ElementPtr begin_element;
	Geoxiom::Lex::ElementPtr end_element;

protected:
	void reset(bool release) {
		pattern = NULL;
		wildcard = NULL;
		if (release) {
			for (std::vector<Node *>::iterator i = children.begin(), e = children.end();
				 i != e; i++)
				 delete *i;
		}
		children.clear();
		begin_element = end_element = NULL;
	}

public:
	Node() : pattern(NULL), wildcard(NULL), children() { }
	~Node() { reset(true); }

} *NodePtr, *NodeArray;

}
}

#endif
